import Vue from "vue";

export { default as StepBackwardOutline } from "@ant-design/icons/lib/outline/StepBackwardOutline";
export { default as PlusOutline } from "@ant-design/icons/lib/outline/PlusOutline";
export { default as LeftOutline } from "@ant-design/icons/lib/outline/LeftOutline";
export { default as RightOutline } from "@ant-design/icons/lib/outline/RightOutline";
export { default as EyeOutline } from "@ant-design/icons/lib/outline/EyeOutline";
export { default as DeleteOutline } from "@ant-design/icons/lib/outline/DeleteOutline";

// const MAP_RESULT = {};

// [
//   '<a-icon type="delete" />',
//   '<a-icon type="eye" />',
//   '<a-icon type="plus" />'
// ].map(item => {
//   const res = _ICON_(item);
//   MAP_RESULT[res.name] = res.component;
// });

// module.exports = MAP_RESULT;

window._ICON_ = iconStr => {
  function toUpperCase(str) {
    return str[0].toUpperCase() + str.slice(1);
  }

  const MAP = {
    outlined: { type: "Outline", theme: "outline" },
    filled: { type: "Fill", theme: "fill" },
    twoTone: { type: "TwoTone", theme: "twotone" }
  };

  const themeArray = iconStr.match(/theme="(.[^"]+)"/);

  let theme = themeArray ? themeArray[1] : "outlined";

  const icon =
    iconStr
      .match(/type="(.[^"]+)"/)[1]
      .split("-")
      .map(item => toUpperCase(item))
      .join("") + MAP[theme].type;

  const res = `export { default as ${icon} } from "@ant-design/icons/lib/${MAP[theme].theme}/${icon}"`;

  Vue.prototype.$copyText(res);

  return res;
};
